import axios from 'axios'

const service = axios.create({
    baseURL: import.meta.env.VITE_APP_BASE_API,
    timeout: 600000,
})
//request拦截器
service.interceptors.request.use((config)=>{
    config.headers['Content-Type'] = 'application/json;'
    if(config.url.indexOf('conversation/talk') !== -1){
        config.headers['accept'] = 'text/event-stream;'
    }
    // console.log('config=>',config);
    return config
},(error)=>{
    console.log('error=>',error);
    return Promise.reject(error)
})
//响应拦截器
service.interceptors.response.use((res)=>{
    // console.log('res=>',res);
    return res.data
},(error)=>{
    console.log('error=>',error);
    return Promise.reject(error)
})
export default service;